﻿var mainPlayer: GameObject;
var stunnedTimer: int;
function Start () {
stunnedTimer = 0;
}

function Update () {
	//print("test");
	if (stunnedTimer > 0)
		{
			stunnedTimer = stunnedTimer-1;
			if(stunnedTimer <=0){
				gameObject.tag = "zombie";
			}
			
		}
}

function OnCollisionEnter(collision : Collision) {
    print("collision");
    print(collision.gameObject.tag);
    print(gameObject.tag);
	if(collision.gameObject.tag == "zombie" && gameObject.tag == "human"){
		if(mainPlayer.tag == "admin"){
	    	mainPlayer.SendMessage("zombieKill");
	    }
		gameObject.tag="zombie";
		if(gameObject.name == "First Person Controller"){
		   //killed notification
		   mainPlayer.SendMessage("getKilled");
		}
	} 
	
	else if(collision.gameObject.tag == "stunner" && gameObject.tag == "zombie"){
		//stunned
		gameObject.tag = "stunned";
		stunnedTimer = 1000;
	}
}

function OnControllerColliderHit (hit : ControllerColliderHit) {
	if(hit.gameObject.tag == "zombie" && gameObject.tag == "human"){
		if(mainPlayer.tag == "admin"){
	    	mainPlayer.SendMessage("zombieKill");
	    }
		gameObject.tag="zombie";
		if(gameObject.name == "First Person Controller"){
		   //killed notification
		   mainPlayer.SendMessage("getKilled");
		}
	} 
	
	else if(hit.gameObject.tag == "stunner" && gameObject.tag == "zombie"){
		//stunned
		mainPlayer.SendMessage("getStunned");
		stunnedTimer = 1000;
	} else if (hit.gameObject.tag == "human" && gameObject.tag == "zombie"){
		hit.gameObject.tag = "zombie";
		mainPlayer.SendMessage("killHuman");
	}
}